package cs343;

/**
* <p>
* Title: CS 343 Project: Pong
* </p>
* <p>
* Description: CS 343 Project  
* This class keeps track of the score and alias that is used in the ArrayList
* of the HighScores class
* </p>
* 
* @author Jenny Windsperger, Stirling Pankow, Will Prew, Shane O'Malley-Potting
* @email jennifer.windsperger@my.uwrf.edu, stirling.pankow@my.uwrf.edu,
*        william.prew@my.uwrf.edu, shane.omalley-potting@my.uwrf.edu
* @date December 1st 2011
*/


public class Score implements Comparable<Score>{
	private int score = 0;
	private String alias = "";
	
	/**
	 * alternate constructor that stores an alias an a score 
	 * Postcondition: score = score_in and alias = alias_in
	 */
	public Score(int score_in, String alias_in){
		score = score_in;
		alias = alias_in;
	}
	
	/**
	 * compareTo method that is used for sorting the ArrayList
	 * in the HighScores class
	 * Postcondition: the ArrayList in HighScores is sorted highest to lowest
	 */
	public int compareTo(Score score_in) {
		//temp valiable
        int lastCmp;
        if(score == score_in.score){
        	lastCmp = 0;
        } else if(score > score_in.score){
        	lastCmp = 1;
        } else 
        	lastCmp = -1;
        //if the scores are equal, sort by alias alphabetically
        return (lastCmp != 0 ? lastCmp :
                alias.compareTo(score_in.alias));
    }
	
	/**
	 * toString method that returns a string with the score and alias
	 */
	public String toString(){
		return score+" "+alias;
	}

	/**
	 * Getter for score
	 */
	public int getScore() {
		return score;
	}

	/**
	 * Setter for score
	 * Postcondition: this.score = score 
	 */
	public void setScore(int score) {
		this.score = score;
	}

	/**
	 * Getter for alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * Setter for alias
	 * Postcondition: this.alias = alias
	 */
	public void setAlias(String alias) {
		this.alias = alias;
	}
}
